<template>
  <div class="form_init">
      <el-tabs v-model="activeName" @tab-click="handleClick" class="tabTable">
        <el-tab-pane label="登录日志" name="login">
            <loginTable :list="logList"></loginTable>
        </el-tab-pane>
        <el-tab-pane label="产品日志" name="goods">
            <goodsTable :list="goodsList"></goodsTable>
        </el-tab-pane>
        <el-tab-pane label="盘点日志" name="check">
            <checkTable :list="checkList"></checkTable>
        </el-tab-pane>
      </el-tabs>
  </div>
</template>
<script>
import loginTable from "./loginTable"
import goodsTable from "./goodsTable"
import checkTable from "./checkTable"
export default {
  data() {
    return {
      activeName: 'login',
      logList:[],
      goodsList:[],
      checkList:[]
    };
  },
  components: {
    "loginTable": loginTable,
    "goodsTable":goodsTable,
    "checkTable":checkTable
  },
  created: function() {
    this.getLoginList()
  },
  methods: {
    handleClick(tab, event) {
      if(tab.name == 'goods' && this.goodsList.length == 0){
        this.getGoodsList()
      }
      if(tab.name == 'check' && this.checkList.length == 0){
        this.getCheckList()
      }

    },
    getLoginList:function(){
       var data = {
        store_id:localStorage.getItem('store_id')
      }
      var that = this
      this.$get('loginLog/all',data).then((res) => {
        that.logList = res.data
      })
    },
    getCheckList:function(){
      var data = {store_id:localStorage.getItem('store_id')}
      var that = this
      this.$get('check/all',data).then((res) => {
        that.checkList = res.data
      })
    },
    getGoodsList:function(){
      var data = {
        store_id:localStorage.getItem('store_id')
      }
      var that = this
      this.$get('loginLog/goodsLog',data).then((res) => {
        that.goodsList = res.data
      })
    }
  }
};
</script>
<style>
.form_init{
  padding:20px 20px 20px 20px;
}
</style>